package com.xiaoma.future;

import java.util.concurrent.CompletableFuture;

public class ThenApply {
    public static void main(String[] args) {
       /* CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {
            int result = 100;
            System.out.println("第一次运算：" + result);
            return result;
        }).thenApply(number -> {
            int result = number * 3;
            System.out.println("第二次运算：" + result);
            return result;
        });

        System.out.println(future.join());*/
        CompletableFuture<String> compose = CompletableFuture
                .supplyAsync(() -> "Hello CompletableFuture!")
                .thenCompose(s-> {
                    return CompletableFuture.supplyAsync(() -> s + " abc");
                });

        System.out.println(compose.join());


    }
}
